<template>
    <div id="page-currency-list">
        <div class="header-panel">
            <div class="control">
                <div class="operations">
                    <el-button @click="onUpdate">货币同步 <i class='material-icons'>redo</i></el-button>
                </div>
            </div>
            
        </div>
	
		<div class="container">
			<el-table
			    ref="multipleTable"
			    :data="list"
			    border
			    tooltip-effect="dark"
                v-loading='table_loading'
                element-loading-text="拼命加载中"
                >
                <el-table-column prop="currency_id" label="" width="34">
                    <template scope="scope"><div></div></template>
                </el-table-column>
			    <el-table-column prop="currency_id" label="ID" width="100"></el-table-column>
                <el-table-column prop="currency_title" label="货币名称"></el-table-column>
                <el-table-column prop="currency_code" label="货币简称"></el-table-column>
                <el-table-column prop="symbol_left" label="前置货币符号"></el-table-column>
                <el-table-column prop="symbol_right" label="后置货币符号"></el-table-column>
                <el-table-column prop="update_time" label="更新时间" width="200"></el-table-column>
			</el-table>
            <el-pagination
                small
                layout="prev, pager, next, jumper"
                :page-size="1"
                @current-change="handleCurrentChange"
                :total="page_count"
                >
            </el-pagination>
		</div>
	</div>
</template>

<script>
Vue.http.options.headers = {
  'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
};
export default {
    data() {
      return { 
        multipleSelection: [],
        keyword: "",
        withDel: false,
        page: 1,
        table_loading: false
        , list: []
        , page_count: 0
      }
    }
    , mounted() {
    	this.get();
    }
    , methods: {
    	get() {
            this.table_loading = true;
    		this.$http.get('/currency.php?p='+this.page).then(function(res){
                this.table_loading = false;
    			this.list = res.body.goodsList;
                this.page_count = res.body.pageCount;
    		});
    	}
    	, onUpdate(){
            this.table_loading = true;
            var formdata = new FormData();
                formdata.append('act', 'update');
            this.$http.post('/currency.php', formdata).then( res => {
                // console.log(res.body);
                this.$message(res.body.msg);
                this.get();
            });
        }
        , handleCurrentChange(val){
            this.page = val;
            this.get();
        }
    }
  }
</script>

